package com.example.project10;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 推荐项数据模型类
 * 用于存储推荐列表中每一项的数据
 */
public class RecommendationItem implements Parcelable {
    private int id;
    private String title;
    private String description;
    private String category; // 分类（对应兴趣）
    private String imageUrl; // 图片URL
    private double rating; // 评分

    public RecommendationItem(int id, String title, String description, String category, String imageUrl, double rating) {
        this.id = id;
        this.title = title;
        this.description = description;
        this.category = category;
        this.imageUrl = imageUrl;
        this.rating = rating;
    }

    // Parcelable 构造函数
    protected RecommendationItem(Parcel in) {
        id = in.readInt();
        title = in.readString();
        description = in.readString();
        category = in.readString();
        imageUrl = in.readString();
        rating = in.readDouble();
    }

    public static final Creator<RecommendationItem> CREATOR = new Creator<RecommendationItem>() {
        @Override
        public RecommendationItem createFromParcel(Parcel in) {
            return new RecommendationItem(in);
        }

        @Override
        public RecommendationItem[] newArray(int size) {
            return new RecommendationItem[size];
        }
    };

    // Getter 和 Setter 方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public double getRating() {
        return rating;
    }

    public void setRating(double rating) {
        this.rating = rating;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(title);
        dest.writeString(description);
        dest.writeString(category);
        dest.writeString(imageUrl);
        dest.writeDouble(rating);
    }
}